<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>开关灯</title>
  <script src="./vue-2.4.0.js"></script>
  <style>
    * {
      padding: 0;
      margin: 0;
    }
    html {
      height: 100%;
      width: 100%;
    }
    body {
      width: 100%;
      height: 100%;
    }
    #app {
      width: 100%;
      height: 100%;
    }
    div {
      width: 100%;
      height: 100%;
    }
    button {
      width: 66px;
      height: 88px;
    }
  </style>
</head>
<body>
<div id="app">
  <div :style="backColor">
    <button @click="switchBtn">{{text}}</button>
  </div>

</div>
</body>
<script>
  let vm = new Vue({
    el: '#app',
    data: {
      text: '开灯',
      backColor: 'background-color: #fff'
    },
    methods: {
      switchBtn() {
        console.log(this.backColor)
        if(this.backColor == 'background-color: #fff') {
          this.backColor = 'background-color: black'
        } else {
          this.backColor = 'background-color: #fff'
        }
      }
    }
  })
</script>
</html>